#ifndef _CONSOLE_H
#define _CONSOLE_H
#pragma once

#include "Engine.h"
#include <deque>

using namespace std;

class CFontEntry;

#define MAXCONSOLEHISTORY_SZ 512

class CConsole
{
private:
	const CFontEntry* _font;
	CRect _r;
	deque<char*> _rbuff;

	BOOL _push_line(char* line, int sz);
public:
	CConsole():_r(10, 10, 320, 100), _font(NULL){}
	CConsole(const CRect& r):_r(r), _font(NULL){}
	void init();
	void setRect(CRect& r){_r = r;}
	BOOL pushLine(const char* line, ...);
	void _print_lines();
};

inline BOOL CConsole::pushLine(const char* line, ...)
{
	char		text[256];
	va_list		ap;
	int sz;

	va_start(ap, line);
    sz = vsprintf(text, line, ap);
	va_end(ap);
	if (sz < 0) return FALSE;
	return _push_line(text, sz);
}

#endif